<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>京东商城●后台管理</title>
    <base href="/tpshop/" />
    <link href="/tpshop/Public/admin/css/bootstrap.min.css" rel="stylesheet">
<link href="/tpshop/Public/admin/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<!-- Toastr style -->
<link href="/tpshop/Public/admin/css/plugins/toastr/toastr.min.css" rel="stylesheet">
<!-- Gritter -->
<link href="/tpshop/Public/admin/js/plugins/gritter/jquery.gritter.css" rel="stylesheet">
<link href="/tpshop/Public/admin/css/animate.css" rel="stylesheet">
<link href="/tpshop/Public/admin/css/style.css" rel="stylesheet">
<link href="/tpshop/Public/admin/lightbox/css/lightbox.css" rel="stylesheet">
    <!-- Mainly scripts -->
<script src="/tpshop/Public/admin/js/jquery-2.1.1.js"></script>
<script src="/tpshop/Public/admin/js/bootstrap.min.js"></script>
<script src="/tpshop/Public/admin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/tpshop/Public/admin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<!-- Custom and plugin javascript -->
<script src="/tpshop/Public/admin/js/inspinia.js"></script>
<script src="/tpshop/Public/admin/js/plugins/pace/pace.min.js"></script>
<!-- jQuery UI -->
<script src="/tpshop/Public/admin/js/plugins/jquery-ui/jquery-ui.min.js"></script>
<script src="/tpshop/Public/admin/lightbox/js/lightbox.js"></script>
</head>
<body>
    <div id="wrapper">
        <nav class="navbar-default navbar-static-side" role="navigation">
    <div class="sidebar-collapse">
        <ul class="nav metismenu" id="side-menu">
            <li class="nav-header">
                <div class="dropdown profile-element text-center"> <span>
                    <img style="width:50%" alt="image" class="img-circle" src="/tpshop/Public/admin/img/1.jpg" />
                     </span>
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                    <span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">
                    <?php echo ($_SESSION['admin_name']); ?></strong>
                     </span></span> </a>
                </div>
                <div class="logo-element">
                   <span><?php echo ($_SESSION['admin_name']); ?></span>
                </div>
            </li>
            <li <?php if(CONTROLLER_NAME == Index ): ?>class="active"<?php endif; ?>>
                <a href="<?php echo U('admin/index/index');?>"><i class="fa fa-home"></i><span class="nav-label">主页</span></a>
            </li>
            <li <?php if(CONTROLLER_NAME == Order ): ?>class="active"<?php endif; ?>>
                <a href=""><i class="fa fa-edit"></i><span class="nav-label">订单管理</span></a>
            </li>
            <li <?php if(CONTROLLER_NAME == Catalog ): ?>class="active"<?php endif; ?>>
                <a href=""><i class="fa fa-th-list"></i><span class="nav-label">分类管理</span><span class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li><a href="<?php echo U('admin/catalog/index');?>">分类管理</a></li>
                    <li><a href="<?php echo U('admin/product/index');?>">商品管理</a></li>
                </ul>
            </li>
            <li <?php if(CONTROLLER_NAME == Product ): ?>class="active"<?php endif; ?>>
                <a href="<?php echo U('admin/product/index');?>"><i class="fa fa-shopping-cart"></i><span class="nav-label">商品管理</span></a>
            </li>
            <li <?php if(CONTROLLER_NAME == User ): ?>class="active"<?php endif; ?>>
                <a href="<?php echo U('admin/user/index');?>"><i class="fa fa-group"></i><span class="nav-label">会员管理</span></a>
            </li>
            <li <?php if(CONTROLLER_NAME == Website ): ?>class="active"<?php endif; ?>>
                <a href=""><i class="fa fa-wrench"></i><span class="nav-label">网站设置</span></a>
            </li>
        </ul>
    </div>
</nav>
        <div id="page-wrapper" class="gray-bg dashbard-1">
            <div class="row border-bottom">
    <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
    <div class="navbar-header">
        <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
    </div>
        <ul class="nav navbar-top-links navbar-right">
            <li>
                <span class="m-r-sm text-muted welcome-message">欢迎登录京东商城后台管理.</span>
            </li>
            <li>
                <a href="<?php echo U("admin/auth/logout");?>">
                    <i class="fa fa-sign-out"></i>Log out
                </a>
            </li>
        </ul>
    </nav>
</div>
        <div class="row">
            <div class="col-lg-12">
                <div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-md-6">
        <h2>编辑宝贝</h2>
        <ol class="breadcrumb">
            <li>
                <a href="index.html">主页</a>
            </li>
            <li class="active">
                <strong>编辑宝贝</strong>
            </li>
        </ol>
    </div>
    <div class="col-md-6">
    </div>
</div>


<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>编辑宝贝</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="fa fa-wrench"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">
                    <li><a href="#">Config option 1</a>
                    </li>
                    <li><a href="#">Config option 2</a>
                    </li>
                </ul>
                <a class="close-link">
                    <i class="fa fa-times"></i>
                </a>
            </div>
        </div>
        <div class="ibox">
            <div class="ibox-content">
                <form action="<?php echo U('admin/product/do_edit');?>" method="post" class="form-horizontal">
                    <input type="hidden" name="id" value="<?php echo ($product['id']); ?>" />
                    <div class="form-group"><label class="col-sm-2 control-label">宝贝名称：</label>
                        <div class="col-sm-8"><input type="text" value="<?php echo ($product['title']); ?>" name="title" class="form-control"></div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                    <label class="col-sm-2 control-label">宝贝分类：</label>
                        <div class="col-sm-2">
                            <select id="level1" class="form-control">
                                <?php if(is_array($level1_data)): $i = 0; $__LIST__ = $level1_data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$l1): $mod = ($i % 2 );++$i;?><option <?php if($l1['id'] == $level1): ?>selected="selected"<?php endif; ?> value="<?php echo ($l1["id"]); ?>"><?php echo ($l1["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                        <div  class="col-sm-2">
                        <input type="hidden" id="level2_defult" value="<?php echo ($level2); ?>">
                            <select id="level2" class="form-control">
                            </select>
                        </div>
                        <div  class="col-sm-2">
                        <input type="hidden" id="level3_defult" value="<?php echo ($level3); ?>">
                            <select id="level3" class="form-control">
                            </select>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">图片：</label>
                            <div class="col-sm-4"><input id="img" value="<?php echo ($product['img']); ?>" type="text" name="img" class="form-control"></div>
                            <div class="col-sm-2"><a href="#" id="upload" class="btn btn-info">上传</a></div>
                            <div class="col-sm-4">
                                <div id="preview"></div>
                            </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                            <label class="col-sm-2 control-label">宝贝价格：</label>
                            <div class="col-sm-3"><input type="text" value="<?php echo ($product['price']); ?>" name="price" class="form-control"></div>
                            <label class="col-sm-2 control-label">宝贝库存：</label>
                            <div class="col-sm-3"><input type="text" value="<?php echo ($product['stock']); ?>" name="stock" class="form-control"></div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group"><label class="col-sm-2 control-label">宝贝描述：</label>
                        <div class="col-sm-8">
                            <textarea class="form-control" rows="3" type="text" name="desc"><?php echo ($product['desc']); ?></textarea>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group"><label class="col-sm-2 control-label">宝贝详情：</label>
                        <div class="col-sm-8">
                            <textarea id="content" rows="100" class="form-control" type="text" name="content"><?php echo ($product['content']); ?></textarea>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group"> 
                        <div class="col-sm-2"></div>
                        <div class="col-sm-8">
                            <button class="btn btn-primary" >保存</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script src="/tpshop/Public/admin/js/plugins/kindeditor/kindeditor-all.js"></script>
<script src="/tpshop/Public/admin/js/plugins/kindeditor/lang/zh-CN.js"></script>
<script src="/tpshop/Public/admin/js/plugins/jquery.upload.js"></script>
<script type="text/javascript">
   editor = KindEditor.create('#content', {
        uploadJson : "<?php echo U('admin/util/uploadJson');?>",
        allowFlashUpload: false,
        allowMediaUpload: false,
        allowFileUpload: false,
        formatUploadUrl: false,
    });
    function level1Chagne(){
        var id = $('#level1').val();
        $.get("<?php echo U('admin/product/getCatalog');?>",{id:id},function(data){
            var level2_defult = $('#level2_defult').val();
            var str = "";
            for (var i = 0; i < data.length; i++) {
                isSelected = data[i].id == level2_defult?'selected="selected"':"";
                str += '<option '+isSelected+' value="'+data[i].id+'">'+data[i].name+'</option>';
            }
            $('#level2').html(str);
            level2Chagne();
        })
    }
    function level2Chagne(){
        var id = $('#level2').val();
        $.get("<?php echo U('admin/product/getCatalog');?>",{id:id},function(data){
            var level3_defult = $('#level3_defult').val();
            var str = "";
            for (var i = 0; i < data.length; i++) {
                isSelected = data[i].id == level3_defult?'selected="selected"':"";
                str += '<option '+isSelected+' value="'+data[i].id+'">'+data[i].name+'</option>';
            }
            $('#level3').html(str);
        })
    }
    $('#level1').change(level1Chagne);
    $('#level2').change(level2Chagne);
    level1Chagne();


   $("#upload").click(function(){
        $.upload({
            url: '<?php echo U("admin/util/upload");?>', 
            fileName: 'file', 
            dataType: 'text',
            onSend: function() {
                return true;
            },
            onComplate: function(data) {
                if(data.indexOf("upload") >=0 ){
                    $("#img").val(data);
                    $("#preview").html('<img style="height:80px;" src="/tpshop'+data+'" />');
                }else{
                    alert(data);
                }
            }
        });
        return false;
    })
</script>
                <div class="footer">
    <div class="text-center">
        <strong>Copyright</strong> © 2004 - 2016  京东JD.com 版权所有  |  消费者维权热线：4006067733
    </div>
</div>
            </div>
        </div>
        </div>
    </div>
</body>
</html>